#import <UIKit/UIKit.h>
#import <EventKit/EventKit.h>

#import "framework/FWPlugin.h"
#import "framework/FWApplicationDelegate.h"

#import "PIPlugin.h"


@class PIEvent;

@interface PIEventPlugin : PIPlugin <FWApplicationDelegate>
{
    NSDate* alarmDate;
    NSDate* muteUntilDate;
    NSURL *alarmSound;
    CFURLRef alarmSoundURLRef;
	SystemSoundID alarmSoundObject;
    
    BOOL lastDisplayWasLocked;
}


@property (retain) EKEventStore* eventStore;
@property (assign, getter = isEventStoreUpdated) BOOL eventStoreUpdated;
@property (readonly) NSDate* alarmDate;
@property (readonly) NSDate* muteUntilDate;


// Object management
- (void)dealloc;

- (NSDate*)reminderEndTimeForEvent:(PIEvent*)event startTime:(NSDate*)start;
- (void)checkForNewAlarmsForDate:(NSDate*)date;
- (void)notifyNextTimerEventDate:(NSDate*)date;

- (void)scheduleAlarmSound:(NSString *)sound forDate:(NSDate *)date withItem:(PIEvent*)item playNow:(BOOL)play;
- (void)scheduleAlarmSound:(NSString*)sound forDate:(NSDate*)date duration:(NSTimeInterval)duration playNow:(BOOL)play;
- (void)cancelAlarmSound;
- (BOOL)isAlarmSoundScheduled;
- (void)muteAlarmUntilDate:(NSDate*)date;

- (void)calendarUpdated:(NSNotification*)notif;

- (void)batteryStateChanged:(NSNotification*)notif;
- (void)batteryLevelChanged:(NSNotification*)notif;

- (void)closeMenuClicked:(UIBarButtonItem*)sender;
- (void)muteAlarmClicked:(UIBarButtonItem*)sender;
- (void)unmuteAlarmClicked:(UIBarButtonItem*)sender;
- (void)snoozeAlarmClicked:(UIBarButtonItem*)sender;
- (void)sleepAlarmClicked:(UIBarButtonItem*)sender;
- (void)cancelAlarmClicked:(UIBarButtonItem*)sender;
- (void)showPreviewClicked:(UIBarButtonItem*)sender;


@end
